<template>
  <div class="right-muen">
    <Scroll class="con" @scrolls="scrolls">
      <div class="content">
        <div class="item" v-for="(item, index) in props.rightData" :key="index">
          <van-image :src="item.image" class="img">
            <template v-slot:loading>
              <van-loading type="spinner" size="20" />
            </template>
          </van-image>
          <p>{{ item.title }}</p>
        </div>
        <Tablist
          class="tablist"
          @checkout="checkout"
          :tablist="state.tablist"
        />
      </div>
    </Scroll>
  </div>
</template>

<script setup="props">
import { defineProps, reactive, getCurrentInstance } from "vue";
import Scroll from "@/components/common/Scroll.vue"; //滑动组件
import Tablist from "./TabList.vue"; //滑动组件
const ctx = getCurrentInstance();
const props = defineProps({
  rightData: {
    type: Array,
    default: () => [],
  },
});
const state = reactive({
  tablist: ["流行", "新款", "精选"],
});
const checkout = (n, name) => {
  console.log(n);
};
// Scroll 传递给父亲  
const scrolls = (item) => {
  ctx.emit("scroll",item);
};

</script>

<style scoped lang="scss">
.tablist {
  width: 100%;
}
.right-muen {
  display: flex;
  flex-direction: column;
}
.con {
  position: absolute;
  left: 70px;
  top: 44px;
  bottom: 35px;
  overflow: hidden;
  right: 0;
}
.content {
  display: flex;
  flex-wrap: wrap;
  width: 100%;
  padding: 20px 8px;
  box-sizing: border-box;
  justify-content: center;
}
.item {
  width: 30%;
  display: flex;
  align-items: center;
  flex-direction: column;
  .img {
    width: 68px;
    height: 68px;
  }
}
p {
  font-size: 12px;
  color: #666666;
  text-align: center;
}
</style>